﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Security;

namespace netdom
{
    public partial class Form2 : Form
    {
        private Form1 form1;
        public Form2(Form1 form1)
        {
            InitializeComponent();
            button1.Enabled = false;
            this.form1 = form1;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string userName = userNameTextBox.Text;
            SecureString password = new SecureString();
            foreach (var c in passwordTextBox.Text) { password.AppendChar(c); }
            form1.setUserNameAndPassword(userName, password);
            this.Close();
        }

        private void enableButton()
        {
            if (userNameTextBox.TextLength != 0 && passwordTextBox.TextLength != 0)
            {
                button1.Enabled = true;
            }
            else
                MessageBox.Show("Please enter your credentials");
        }

        private void passwordTextBox_TextChanged(object sender, EventArgs e)
        {
            enableButton();
        }
    }
}
